package tds.model15.version1;


import java.util.ArrayList;
import java.util.List;

/**
 * @Company 杭州先锋电子技术股份有限公司
 * @ClassName Boss
 * @Description 老板类（被观察者）
 * @author tds
 * @Date 2020/1/30 16:12
 * @version 1.0.0
 */
public class Boss implements Subject {

    /**
     * 老板状态
     */
    private String state;

    /**
     * 观察者集合
     */
    private List<Observer> observers = new ArrayList<>();

    @Override
    public void attach(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObservers() {
        for (Observer observer : observers){
            observer.update();
        }
    }

    public void setState(String state) {
        this.state = state;
    }

    @Override
    public String getSubjectState() {
        return state;
    }
}
